<template>
    <div>
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>权限管理</el-breadcrumb-item>
            <el-breadcrumb-item>权限列表</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card>
            <el-table :data="rightsList" border stripe>
                <el-table-column type="index"></el-table-column>
                <el-table-column prop="authName" label="权限名称"></el-table-column>
                <el-table-column prop="path" label="路径"></el-table-column>
                <el-table-column prop="level" label="权限等级">
                    <template v-slot="scope">
                        <div v-for="item in levelText" :key="item.level">
                            <el-tag v-if="item.level == scope.row.level" :type="item.type">{{item.name}}</el-tag>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
    </div>
</template>

<script>
import {
    getRights
} from  "@/request/api"; 
export default {
    name: 'rights',
    data(){
        return{
            rightsList: [],
            levelText: [
                {level: 0,name: '超级',type: 'danger'},
                {level: 1,name: '一级',type: 'warning'},
                {level: 2,name: '二级',type: 'success'},
                {level: 3,name: '三级',type: 'info'},
            ]
        }
    },
    created(){
        this.getRightslist()
    },
    methods:{
        getRightslist(){
            getRights('list').then((res)=>{
                if(res.meta.status == 200){
                    this.rightsList = res.data;
                }else{
                    this.$message.error(res.meta.msg);
                    return false;
                }
            })
        }
    }
}
</script>

<style lang="less" scoped>

</style>